package com.key.controller.admin.setting;

import com.key.common.R;
import com.key.entity.AssetType;
import com.key.service.AssetTypeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
 *
 * @author liu
 *
 */
@Controller
@RequestMapping("/asset_type")
@Api(value = "资产分类管理",tags = "资产分类管理接口API")
public class AssetTypeController {
    @Autowired
    private AssetTypeService assetTypeService;

@RequestMapping(value = "/addAssetType",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "添加资产分类",notes = "添加资产分类信息",httpMethod = "post", response = R.class)
@ApiResponses({
        @ApiResponse(code=200,message="成功"),
        @ApiResponse(code=401,message="token为空"),
        @ApiResponse(code=1005,message="Token过期"),
        @ApiResponse(code=1006,message="Token验证不通过"),
        @ApiResponse(code=500,message="后台服务错误")
})
    public R addAssetType(@RequestBody  @ApiParam(name = "assetType",value = "资产分类",required = true)AssetType assetType){

    return assetTypeService.addAssetType(assetType);
}

    @RequestMapping(value = "/findAllAssetType",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询所有资产分类",notes = "查询资产分类表所有信息",httpMethod = "get", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R findAllAssetType(){

        return assetTypeService.findAllAssetsType();
    }

    @RequestMapping(value = "/findAssetType",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询资产分类",notes = "查询资产分类表选中信息回显",httpMethod = "get", response = R.class)
    @ApiImplicitParam(name = "assetTypeId",value = "资产分类Id",paramType = "query",dataType = "int",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R findAssetType(@RequestParam("assetTypeId") Integer assetTypeId){

        return assetTypeService.findAssetsType(assetTypeId);
    }

    @RequestMapping(value = "/updateAssetType",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "修改资产分类",notes = "修改资产分类信息",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateAssetType(@RequestBody  @ApiParam(name = "assetType",value = "资产分类",required = true)AssetType assetType){

        return assetTypeService.updateAssetType(assetType);
    }

    @RequestMapping(value = "/deleteAssetType",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "删除资产分类",notes = "删除资产分类表信息",httpMethod = "post", response = R.class)

    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteAssetType(@RequestBody @ApiParam(name = "assetTypeIds",value = "资产分类Id集合",required = true) List<Integer> assetTypeIds){

        return assetTypeService.deleteAssetTypes(assetTypeIds);
    }

    @RequestMapping(value = "/disableAssetType",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "禁用资产分类",notes = "修改资产分类状态",httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "assetTypeId",value = "资产分类Id",paramType = "query",dataType = "int",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R disableAssetType(@RequestParam("assetTypeId") Integer assetTypeId){

        return assetTypeService.disableAssetType(assetTypeId);
    }

    @RequestMapping(value = "/enableAssetType",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "解禁资产分类",notes = "解禁资产分类状态",httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "assetTypeId",value = "资产分类Id",paramType = "query",dataType = "int",required = true)
    @ApiResponses({
            @ApiResponse(code=200,message="成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R enableAssetType(@RequestParam("assetTypeId") Integer assetTypeId){
        return assetTypeService.enableAssetType(assetTypeId);
    }

}
